    var $userId=$('#user_id').val();
	var $proId;
	var $Id;
	var $sku_id=$('#sku_id').val();
	var $promotion_id=$('#payment_id').val();
//点击收藏
    $(".collect").click(function(){ 
    	$proId=$('#pro_id').val();
    	if($(".icon-collect").hasClass("shoucang")){	  
    		del_colct_detail();
    	}else{
    	    add_colct();
    	};
    });
 //点击取消收藏
$('.can-clt').live("click",function(){	//点击未知元素不能用click（）
	var $index=$(this).parents("li").index();
	$Id=$(this).parents("li").find('.Id').val();
	del_colct($index);
})
//添加收藏
 function add_colct(){ 
    		$.ajax({
    			type:"post",
    			url:"../../favorite/Index/addMyFavorite",
    			datatype:"json",
    			data:{"user_id":$userId,"pro_id":$proId,"sku_id":$sku_id,"promotion_id":$promotion_id,"source":1},
    			success:function(msg){
					var data=eval("("+msg+")");
					if(data.status==200){
    					error("添加收藏成功!");
    					$('.sctxt').text("已收藏");
    					$(".icon-collect").addClass("shoucang");
    				  }else{
    				  		error(data.errormsg);
    				  }
    			}   			
    		});
    	}
//取消收藏   
    	function del_colct(index){
    		$.ajax({
    			type:"post",
    			url:"../../favorite/Index/delMyFavorite",
    			datatype:"json",
    			data:{"user_id":$userId,"id":$Id,"source":1},
    			success:function(msg){
    				var data=eval("("+msg+")");
    				if(data.status==200){
    					error("取消收藏成功！");   
    					$('.sctxt').text("收藏");
	    			    delhtml(index)	    				
    				}else{
    				  		error(data.errormsg);
    				  }
    				
    			}   
    		});
    	};
//详情页取消收藏   
    function del_colct_detail(){
    		$.ajax({
    			url:"../../favorite/Index/delMyFavoriteByUserId",
    			type:"post",
    			datatype:"json",
    			data:{"user_id":$userId,"pro_id":$proId,"promotion_id":$promotion_id,"source":1},
    			success:function(msg){
    				var data=eval("("+msg+")");
    				if(data.status==200){
    					error("取消收藏成功！");   
    					$('.sctxt').text("收藏");
    					$(".icon-collect").removeClass("shoucang");	    				
    				}else{
    				  		error(data.errormsg);
    				  }
    				
    			}   
    		});
    };
//删除对应商品    	
       function delhtml(index){
       	$(".collectList li").eq(index).remove();
        if($(".collectList li").length<1){
            var html='';
               html+='<div class="nodata">'+
            '<p class="no-icon wdgwc"></p>'+
            '<p class="nodatatip">您的收藏夹空空如也~</p>'+
            '<p class="nodatatip2">快去挑选宝贝吧</p>'+
            '<p><a href="http://static.malls.tm/product/Index/PromotionList" class="gonew">去收藏</a></p>'+
            '</div>';
            $(html).appendTo("body");
        }
       };
//加载更多
$('.loadBtn').click(function(){
	var offset=$('.collectList li').length;
	var num=1;
	var count;
	$.ajax({
		type:"post",
		url:"../../favorite/Index/index",
		dataType:"json",
		data:{"user_id":$userId,"offset":offset,"limit":num},
		success:function(msg){
			var boxes=[];
			var datalenght;
			function show(){
				datalenght=msg.stdclass.list.length;
				for(var i=0;i<datalenght;i++){
					boxes.push(
			     '<li class="clearfix" >' +		
    		     '<div class="fl w33 pd-top-15"><a href="http://static.malls.tm/product/Index/ProdcutDetail?promotion_id='+msg.stdclass.list[i].promotion_id+'&pro_id='+msg.stdclass.list[i].pro_id+         '&sku_id='+msg.stdclass.list[i].sku_id+'"><img src="'+msg.stdclass.list[i].src+'"></a></div>'+
    		     '<div class="fl mr-left-20 three-fifths">'+
				 '<input class="Id" type="hidden" name="id" value="'+msg.stdclass.list[i].id+'">'+
    			 '<h2><a class="font30 c-666" href="http://static.malls.tm/product/Index/ProdcutDetail?promotion_id='+msg.stdclass.list[i].promotion_id+'&pro_id='+msg.stdclass.list[i].pro_id+'&sku_id='+msg.stdclass.list[i].sku_id+     '">'+msg.stdclass.list[i].shortName+'</a></h2>'+
    		     '<h3><a class="font24 c-999" href="http://static.malls.tm/product/Index/ProdcutDetail?promotion_id='+msg.stdclass.list[i].promotion_id+'&pro_id='+msg.stdclass.list[i].pro_id+'&sku_id='+msg.stdclass.list[i].sku_id+         '">'+msg.stdclass.list[i].catName+msg.stdclass.list[i].proContent+'</a></h3>'+
    			 '<p class="clearfix"><span class="font30 fl c-purp">￥'+msg.stdclass.list[i].retailPrice+'</span><span class="fr can-clt mr-left-20 font20 t-center">取消收藏</span></p>' +  				
    		     '</div> </li>'		  		    	
				 );					
				}
				return boxes.join("");				
			}
			count=msg.count;
			var $boxes=$(show());
			$('.collectList').append($boxes);
			if(offset+num>=count){
				$(".loadBtn .moreshow").remove();
			}
		}
	});
})

